package neuronalenetzeelearning.model;

// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
// #[regen=yes,id=DCE.5F9906BB-CCF6-2B53-BF7B-972D60C32956]
// </editor-fold>
/**
 * Eigenschaften von Kanten eines Graphen.
 * @author Maria
 */
public class Edge {

    public final static double DEFAULT_WEIGHT = 0.0;
    private String name;
    private static int instanceCount;
    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.35704F90-4F3C-5CA7-2441-3ABF5EAACEA3]
    // </editor-fold>
    /**
     * Beginn einer Kante
     */
    private Node from;
    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.2135E120-CB2C-0366-A36B-259C1F199931]
    // </editor-fold>
    /**
     * Ende einer Kante (Spitze)
     */
    private Node to;
    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.FA63AC92-0D6B-898D-DE82-0758AE5A9104]
    // </editor-fold>
    private double weight;

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.6FDD4B7E-7E32-B5D5-7F33-0BC14236442C]
    // </editor-fold>
    private Edge() {
        this(null, null, DEFAULT_WEIGHT, "Edge" + instanceCount);
    }

    /**
     * Konstruktor
     * @param from woher
     * @param to wohin
     * @param weigth Gewicht
     * @param name Nummer
     */
    public Edge(Node from, Node to, double weigth, String name) {
        instanceCount++;    //instance count is for numbering unnamed Edges
        this.from = from;
        this.to = to;
        this.weight = weigth;
        this.from.addConnectedEdge(this);
        this.to.addConnectedEdge(this);
        this.name = "Von "+this.from.getName()+" zu "+this.to.getName();
    }

    public Edge(Node from, Node to, String name) {
        this(from, to, DEFAULT_WEIGHT, name);
    }

    public Edge(Node from, Node to, double weigth) {
        this(from, to, weigth, "Edge" + instanceCount);
    }

    public Edge(Node from, Node to) {
        this(from, to, DEFAULT_WEIGHT, "Edge" + instanceCount);
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,regenBody=yes,id=DCE.3C818CDE-C23A-3928-114D-D4EAF1340064]
    // </editor-fold>
    /**
     * liefert Start-knoten
     */
    public Node getFrom() {
        return from;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,regenBody=yes,id=DCE.1D5FE51B-3209-C233-89CC-75B9B4CBB163]
    // </editor-fold>
    /**
     * setze Start-Knoten der kante
     * @param from aus welchem Knoten kommt eine Kante
     */
    public void setFrom(Node from) {
        this.from = from;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,regenBody=yes,id=DCE.C062CB01-DB53-A1B7-A962-0E7A2D51D9C4]
    // </editor-fold>
    /**
     * liefert ZielKnoten der Kante
     * @return liefert ZielKnoten der Kante
     */
    public Node getTo() {
        return to;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,regenBody=yes,id=DCE.7253EB88-4EEC-66AE-602C-8217C4E0345D]
    // </editor-fold>
    /**
     * setzte Zielknoten der Kante
     * @param to in welchen Knoten geht eine Kante rein
     */
    public void setTo(Node to) {
        this.to = to;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,regenBody=yes,id=DCE.5DB9038E-0D72-33EC-6A53-3F6244171314]
    // </editor-fold>
    /**
     * liefert Gewichtswert
     * @return Gewichtswerte der Kanten
     */
    public double getWeight() {
        return weight;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,regenBody=yes,id=DCE.859D5134-AACF-8355-628B-06DF7A14874A]
    // </editor-fold>
    /**
     * setze Gewichtswerte um
     * @param weight
     */
    public void setWeight(double weight) {
        this.weight = weight;
    }

    /**
     *
     * @return Name eines Knoten (als Nummer)
     */
    public String getName() {
        return name;
    }

    /**
     *
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }
}





